package com.xiaotu.spider.license.pipeline;

import com.xiaotu.common.model.TVShootingPlanModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

import java.util.List;

/**
 *
 * 广电总局全国重点网络影视剧拍摄规划登记备案情况
 * @author 张晓
 * @create 2020-06-30 16:49
 */
@Component("TVShootPlanPipeline")
public class TVShootPlanPipeline extends APipeline {

    @Override
    protected void doProcess(ResultItems resultItems, Task task) {
        List<TVShootingPlanModel> dataList = resultItems.get(TVShootingPlanModel.class.getName());
        if (dataList == null || dataList.isEmpty()) {
            return;
        }
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.TV_SHOOT_PLAN_DETAIL_YYYYMMDD);
        dataList.forEach(m -> {
            cacheHandler.hSet(key,m.getUuid(),m);
        });
    }

}
